# https://python-scripts.com/tkinter
# https://pythonforundergradengineers.com/unicode-characters-in-python.html

from pathlib import Path
from tkinter import *
from ctypes import *
#somesummer = CDLL('./somesum.so') # for Linux
somesummer = CDLL('./somesum.DLL') # for Windows

root = Tk()

current_dir = Path.cwd() 

root.geometry('{}x{}'.format(500,130))
canvas = Canvas(root,width=495,height=120)
canvas.pack()

lbl0 = Label(canvas, text="n = ") 
lbl0.config(font=("Courier", 14))
lbl0.grid(column=0, row=0) 

txt0 = Entry(canvas,width=11, foreground="white", background="black")  
txt0.grid(column=1, row=0)  


lbl1 = Label(canvas, text="\u03A3 ") 
lbl1.config(font=("Courier", 44))
lbl1.grid(column=0, row=1) 


lbl2 = Label(canvas, text=" k^( m = ") 
lbl2.config(font=("Courier", 22))
lbl2.grid(column=1, row=1) 

txt2 = Entry(canvas,width=11, foreground="white", background="black")  
txt2.grid(column=2, row=1) 

lbl3 = Label(canvas, text=" ) = ") 
lbl3.config(font=("Courier", 22))
lbl3.grid(column=3, row=1) 

lbl4 = Label(canvas, text='k = 0') 
lbl4.config(font=("Courier", 14))
lbl4.grid(column=0, row=2) 


# def some_sum(n,m):
# 	s = 0
# 	for k in range(n+1):
# 		s += k**m
# 	return s

def clicked1():
	n = int(txt0.get())
	m = int(txt2.get())
	#print(some_sum(n,m))
	result_somesum = somesummer.some_sum(c_ulonglong(n),c_ulonglong(m))
	print("Sum =", result_somesum)


btn1 = Button(canvas, text="sum", command=clicked1)
btn1.grid(column=4, row=1)

root.mainloop()